const app = getApp();
const companyName = app.globalData.companyName;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    phone: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    const phone = wx.getStorageSync('phone');
    this.setData({
      phone
    });
  },
  changePhone: function (e) {
    this.setData({
      phone: e.detail.value
    });
  },
  setPhone:function(){
    const phone = this.data.phone;
    if (phone.length == 0) {
      wx.showToast({
        title: "请输入电话号码",
        icon: 'none'
      });
      return;
    }
    const url = app.globalData.url;
    wx.request({
      url: url + '/management/updateClubPhone',
      data: {
        companyName,
        phone
      },
      method: 'POST',
      success: function (response) {
        if (response.data.success) {
          wx.navigateBack({
            delta: 1
          });
        } else {
          wx.showToast({
            title: response.data.message,
            icon: 'none'
          })
        }
      }
    })
  }
})